#include <a_samp>

#define COLOR_WHITE 0xFFFFFFAA

// ==== CREDITS ====
// [ERP]Snow
// ==== ====

// ==== NOTES ====
// ==== ====

// ==== (c) [ERP]Snow - Ryan [ 2008 ] ====

forward Slide(playerid);
forward IsAChopper(vehicleid);

new Sliding[MAX_PLAYERS];

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("[ERP]Snow's Chopper Sliding [FS] Loaded...");
	print("--------------------------------------\n");
	return 1;
}

public OnPlayerConnect(playerid)
{
	SendClientMessage(playerid, COLOR_WHITE, "This server is using [ERP]Snow's Chopper Sliding [FS].");
	Sliding[playerid] = 0;
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
   new cmd[256];
   new idx;
   new vehicleid;
   cmd = strtok(cmdtext, idx);

   if(strcmp(cmd, "/Slide", true) == 0)
   {
   if(IsPlayerInAnyVehicle(playerid) && IsAChopper(vehicleid) && Sliding[playerid] == 0)
   {
   Sliding[playerid] = 1;
   RemovePlayerFromVehicle(playerid);
   TogglePlayerControllable(playerid, 0);
   SetTimerEx("Slide", 1000, 0, "i", playerid);
   SendClientMessage(playerid, COLOR_WHITE, "You are sliding down the rope.");
   }
   return 1;
}
   if(strcmp(cmd, "/Stop", true) == 0)
   {
   if(Sliding[playerid] == 1)
   {
   Sliding[playerid] = 0;
   TogglePlayerControllable(playerid, 1);
   SendClientMessage(playerid, COLOR_WHITE, "You have stopped sliding.");
   }
   return 1;
           }
   return 0;
}

public Slide(playerid)
{
    if(Sliding[playerid] == 1)
    {
    new Float:X;
    new Float:Y;
    new Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    SetPlayerPos(playerid, X, Y, Z - 5.00);
    SetTimerEx("Slide", 1000, 0, "i", playerid);
    }
	return 1;
}

public IsAChopper(vehicleid)
{
	if(vehicleid >= 0 && vehicleid <= 1) // < Define your Chopper ID's Here
	{
	return 1;
	}
	return 0;
}

strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}

public OnFilterScriptExit()
{
    print("\n--------------------------------------");
	print("[ERP]Snow's Chopper Sliding [FS] UnLoaded...");
	print("--------------------------------------\n");
	return 1;
}

